<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:rg="http://www.ruijie.com.cn/faces/ui"
	xmlns:c="http://java.sun.com/jstl/core"
	template="/layout/contentLayout.xhtml">

	<ui:param name="param_pageTitle"
		value="#{messages.luyuan_crm_menu_order}" />
	<ui:param name="param_navigationUrl" value="/mainNavigation.jsf" />

	<ui:define name="road">
		<span><h:outputLink value="/luyuan/sale/orderListForSale.jsf">我的订单</h:outputLink> &gt;&gt; 新建订单 </span>
	</ui:define>

	<!-- content -->
	<ui:define name="content">
		<rg:areaPanel>
			<rg:wizardPanel id="singleOrderWizard">
				<rg:titlePanel headerTitle="产品清单">
					<rg:table id="productTable" value="#{param_action.productTableModel}" var="item" toolbar="disable">
						<rg:column property="name" title="产品名称" sortable="false" />
						<rg:column property="specification" title="产品规格" sortable="false" />
						<rg:column property="price" title="产品价格" sortable="false" />
						<rg:column property="product.productType.typeName" title="产品类型" sortable="false" />
						<rg:column property="count" title="数量" sortable="false" />
						<rg:column property="gift" title="是否赠品" converter="#{booleanConverter}" sortable="false"  />
						<rg:column property="exchangeIntegral" title="积分兑换" sortable="false" />
					</rg:table>
					<rg:fieldSet >
						<rg:outputText id="freight" value="#{param_action.order.freight}" label="运费(单位：元)" />
						<rg:outputText id="oldAmount"
							value="#{param_action.order.oldAmount}" label="合计(单位：元)" />
					</rg:fieldSet>
				</rg:titlePanel>
				<rg:titlePanel id="shippingInfo" headerTitle="促销优惠">
					<rg:fieldSet column="double">
						<rg:booleanCheckbox id="freeFreight" disabled="#{param_action.order.oldAmount lt 300}" singleLine="true"
							value="#{param_action.order.orderPromotion.freeFreight}" label="减免运费" tip="购买超过300元，可以减免运费">
							<a:support event="onclick" actionListener="#{param_action.computeAmount}" reRender="amount,remarks" ajaxSingle="true" />
						</rg:booleanCheckbox>
						<rg:selectOne id="promotion" itemsProvider="#{promotionProvider}" enableEmpty="true" singleLine="true"
							converter="#{promotionConverter}" value="#{param_action.order.orderPromotion.promotion}" label="促销活动" >
							<a:support event="onchange" actionListener="#{param_action.onPromotionChange}" reRender="promotion_tip,integralDeduction,couponDeduction,amount,remarks" ajaxSingle="true" />
							<ui:define name="tip">
								<h:panelGroup id="promotion_tip" class="tip" layout="block">
									<h:outputLink value="/luyuan/promotion/detailPromotion.jsf?uuid=#{param_action.order.orderPromotion.promotion.id}" 
										 rendered="#{param_action.order.orderPromotion.promotion ne null}"  target="_blank">查看详情</h:outputLink>
								</h:panelGroup>
							</ui:define>
						</rg:selectOne>
						<rg:selectOne id="integralDeduction" itemsProvider="#{integralDeductionProvider}" rendered="#{param_action.isMember()}" 
							readonly="#{param_action.order.orderPromotion.promotion ne null}" disabled="#{param_action.order.orderPromotion.promotion ne null}" 
							value="#{param_action.order.orderPromotion.integralDeduction}" label="积分抵扣" >
							<a:support event="onchange" actionListener="#{param_action.computeAmount}" reRender="amount,remarks" ajaxSingle="true" />
						</rg:selectOne>
						<rg:outputText id="currentIntegral" rendered="#{param_action.isMember()}" 
							value="#{param_action.oldIntegral}" label="可用积分" />
						<rg:selectOne id="couponDeduction" itemsProvider="#{couponDeductionProvider}" rendered="#{param_action.isMember()}" 
							readonly="#{param_action.order.orderPromotion.promotion ne null}" disabled="#{param_action.order.orderPromotion.promotion ne null}"  
							converter="#{couponDeductionConverter}" value="#{param_action.order.orderPromotion.couponDeduction}" label="A/B抵扣" >
							<a:support event="onchange" actionListener="#{param_action.computeAmount}" reRender="amount,remarks" ajaxSingle="true" />
						</rg:selectOne>
						<rg:outputText id="coupons" converter="#{memberCouponsConverter}" rendered="#{param_action.isMember()}"
							value="#{param_action.customer}" label="A/B卷" />
						<rg:booleanCheckbox id="memberDiscount" rendered="#{param_action.isMember()}" 
							value="#{param_action.order.orderPromotion.memberDiscount}" label="会员折扣" >
							<a:support event="onclick" actionListener="#{param_action.computeAmount}" reRender="amount,remarks" ajaxSingle="true" />
						</rg:booleanCheckbox>
						<rg:outputText id="memberLevel" rendered="#{param_action.isMember()}" 
							value="#{param_action.memberIntegral.memberLevel}" label="会员级别" messagePrefix="luyuan_crm_member_memberLevel_" converter="#{messageConverter}"/>
						<rg:inputText id="amount" labelStyle="font-size:14px;color:red;" singleLine="true"
							value="#{param_action.order.amount}" label="优惠价(单位：元)" />
					</rg:fieldSet>
				</rg:titlePanel>

				<rg:titlePanel id="orderRemarks" headerTitle="订单备注">
					<rg:fieldSet column="singleLine">
						<rg:inputArea label="订单备注"
							value="#{param_action.order.remarks}" id="remarks"
							textStyle="width:512px;height:128px;" />
					</rg:fieldSet>
				</rg:titlePanel>
				
				<rg:tipMessage tipHeader="常用打折原因" 
					tipMessage="促销优惠"
					tipMessage2="总价取整折扣"
					tipMessage3="经理授权折扣"
					/>
			</rg:wizardPanel>
		</rg:areaPanel>
	</ui:define>
</ui:composition>